package org.datacoder.geocoding.jurisdiction

import org.datacoder.AllService
import org.datacoder.util.*

class JurisdictionService{

    def congressionalDistrictServiceBean
    def countryServiceBean
    def countyServiceBean
    def heldOfficeServiceBean
    def issueServiceBean
    def municipalityServiceBean
    def representativeDistrictServiceBean
    def senatorialDistrictServiceBean
    def stateServiceBean
    def votingDistrictServiceBean
    def zipCodeServiceBean

    static transactional = true

    /* CRUD */
    public Jurisdiction create(Jurisdiction juris) throws DAOException{
        throw new UnsupportedOperationException("Use the create() method in " +
            "the service for this Jurisdiction's real class: ${juris}.")
    }
    public void save(Jurisdiction juris) throws DAOException{
        ServiceUtils.save(juris)
    }
    public void save(Jurisdiction juris, boolean flush) throws DAOException{
        ServiceUtils.save(juris, flush)
    }
    public void delete(Jurisdiction juris){
        throw new UnsupportedOperationException("Use the delete() method in " +
            "the service for this Jurisdiction's real class: ${juris}.")
    }
    public Jurisdiction merge(Jurisdiction juris){
        return juris.merge()
    }
    public Jurisdiction get(String jurisId){
        return get(Long.parseLong(jurisId))
    }
    public Jurisdiction get(long jurisId){
        return Jurisdiction.get(jurisId)
    }
    public Set<Jurisdiction> getAll(){
        return Jurisdiction.findAll()
    }
    /* END CRUD */

    public void init(AllService allService){
        congressionalDistrictServiceBean = allService.congressionalDistrictService
        countryServiceBean = allService.countryService
        countyServiceBean = allService.countyService
        municipalityServiceBean = allService.municipalityService
        representativeDistrictServiceBean = allService.representativeDistrictService
        senatorialDistrictServiceBean = allService.senatorialDistrictService
        stateServiceBean = allService.stateService
        votingDistrictServiceBean = allService.votingDistrictService
        zipCodeServiceBean = allService.zipCodeService
    }

}

